﻿/**
 * 成品库管理
 * @author liuxl
 */
Ext.ux.EntityViewPanel = function() {
	var desktop = MyDesktop.getDesktop();
	var winV = desktop.getWindow('entity-view-win');
    var tabPanel = null;
	var cId = 0;
	var cName = null;


	if (!winV) {

		var index = 0;
		/**
		 * 栏目 end
		 */

		winV = desktop
				.createWindow( {
					id :'entity-view-win',
					title :'内容管理',
					closable :true,
					modal :'true',
					width :900,
					height :550,
					layout :"border",
					items : [
							{
								id :'chengPin-panel',
								region :'west',
								split :true,
								width :170,
								minSize :175,
								maxSize :400,
								collapsible :true,
								margins:'0 0 5 5',
						        cmargins:'0 0 0 0',
								layout :'fit',
								layoutConfig : {
									animate :true,
									sequence : true
								},
								items : [ {

									xtype :'treepanel',
									id :'chengPinTree',
									border :false,
									rootVisible :true,
									autoScroll :true,
									loader :new Ext.tree.TreeLoader(
											{
												dataUrl :'admin/category.jhtml?method=getUserCategoryTree'
											}),
									root :new Ext.tree.AsyncTreeNode( {
										id :"root",
										text :"栏目导航"
									}),
									listeners : {
										'click' : function(n) {
											try {
												var sn = this.selModel.selNode
														|| {};
												if (n.leaf
														&& n.id != sn.id) {
													var categoryId = n.id;
													if(tabPanel==null)
													{
														
													   tabPanel = Ext.getCmp('chengPin-center');}
													var tab = tabPanel.getComponent( categoryId);
													  if( tab ){
													  	 tabPanel.setActiveTab(tab);
													  }else{
													  	var grid1 = null;
													  	var jsName ="Ext.ux.EntityItem";
													  	var cPanelEntity =null;
													  	/**父id为550为图片栏目*/
													  	//if (n.parentNode.id==picCategoryId){
													  	//	jsName = "Ext.ux.DownLoadFiles";
													  	//}
													  	//315
													  	if(n.parentNode.id == 241){
													  		jsName = "Ext.ux.EntityItemXuanShi";
													  	}
													  	
													  	cPanelEntity = loadClassReturnEntity(jsName,categoryId);
													  	grid1 = cPanelEntity.getGrid();
													  	
													  tabPanel.add({
																				title :n.text + ' 栏目 ',
																				id :categoryId,
																				iconCls :'tabs',
																				layout :'fit',
																				items :grid1,
																				closable :true
																			})
																	.show();
															grid1.store
																	.load( {
																		params : {
																			start :0,
																			limit :20,
																			categoryId :categoryId
																		},callback: listError
																	});
													  }
												}
											} catch (e) {
											}
										}
									}
								
								} ]
							}, {
								xtype :'tabpanel',
								id :'chengPin-center',
								region :'center',
								activeItem :0,
								resizeTabs :true, // turn on tab resizing
								enableTabScroll :true,
								border :false,
								plugins :new Ext.ux.TabCloseMenu(),
								items : [ getStartPanel('chengPinS') ]
							} ]
				});

	
	}
	winV.show();

}